// 包装类型和原始类型
true === new Boolean(true); 
123 === new Number(123); 
'window' === new String('window'); 
console.log(typeof new String('window'));
console.log(typeof 'window');

// 自动装箱和拆箱
const obj = {
    valueOf: () => { 
        console.log('valueOf'); 
        return 123; 
    },
    toString: () => { 
        console.log('toString'); 
        return 'ConardLi'; 
    },
  };
  console.log(obj - 1);
  console.log(`${obj}ConardLi`); 
  
  const obj2 = {
    [Symbol.toPrimitive]: () => { 
        console.log('toPrimitive'); 
        return 123; 
    }
  };
  console.log(obj2 - 1);
  
  const obj3 = {
    valueOf: () => { 
        console.log('valueOf'); 
        return {}; //返回对象
    },
    toString: () => { 
        console.log('toString'); 
        return {}; //返回对象
    },
  };
  console.log(obj3 - 1);  //TypeError: Cannot convert object to primitive value

// 手动装箱和拆箱
var num =new Number("123");  
console.log( typeof num.valueOf() ); //number
console.log( typeof num.toString() ); //string